package com.iafme.service.impl;

import cn.zhxu.bs.BeanSearcher;
import cn.zhxu.bs.operator.Contain;
import cn.zhxu.bs.util.MapUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.iafme.dto.req.ShowingsReqDTO;
import com.iafme.dto.res.ShowingsResDTO;
import com.iafme.model.Showings;
import com.iafme.mapper.ShowingsMapper;
import com.iafme.service.IShowingsService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.systemframework.util.SearchUtl;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author summer
 * @since 2025/01/05 21:14:41
 */
@Service
@AllArgsConstructor
public class ShowingsServiceImpl extends ServiceImpl<ShowingsMapper, Showings> implements IShowingsService {

    private final BeanSearcher beanSearcher;

    @Override
    public Page<ShowingsResDTO> lists(ShowingsReqDTO showingsReqDTO) {
        Map<String, Object> build = MapUtils.builder().page(showingsReqDTO.getPageNum()-1, showingsReqDTO.getPageSize())
                .field(ShowingsResDTO::getProjectName, showingsReqDTO.getProjectName()).op(Contain.class)
                .field(ShowingsResDTO::getLevelName, showingsReqDTO.getLevelName()).op(Contain.class)
                .field(ShowingsResDTO::getName, showingsReqDTO.getName()).op(Contain.class)
                .build();
        return SearchUtl.searchDataList(showingsReqDTO.getPageNum(),showingsReqDTO.getPageSize(),beanSearcher.search(ShowingsResDTO.class,build));
    }
}
